package com.wu.project.admin.api;

import com.wu.project.admin.annotations.Authorization;
import com.wu.project.admin.annotations.Log;
import com.wu.project.admin.component.JsonResult;
import com.wu.project.admin.entity.VehicleClassifyDTO;
import com.wu.project.admin.property.Constants;
import com.wu.project.admin.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/vehicle")
public class VehicleApi {

    @Autowired
    VehicleService vehicleService;

    @Authorization
    @Log(name = "获取车型信息列表")
    @PostMapping(value = "/list", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult vehicleList(@RequestBody VehicleClassifyDTO vehicleClassifyDTO) {
        return vehicleService.queryList(vehicleClassifyDTO);
    }

    @Authorization
    @Log(name = "更新车型信息")
    @PostMapping(value = "/update", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult updateVehicle(@RequestBody VehicleClassifyDTO vehicleClassifyDTO) {
        return vehicleService.updateVehicle(vehicleClassifyDTO);
    }

    @Authorization
    @Log(name = "删除车型信息")
    @PostMapping(value = "/delete", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult deleteVehicle(@RequestBody VehicleClassifyDTO vehicleClassifyDTO) {
        return vehicleService.deleteVehicle(vehicleClassifyDTO);
    }

    @Authorization
    @Log(name = "新增车型信息")
    @PostMapping(value = "/add", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult addVehicle(@RequestBody VehicleClassifyDTO vehicleClassifyDTO) {
        return vehicleService.addVehicle(vehicleClassifyDTO);
    }
}
